/*************************************************************************
	> File Name: test14.c
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/08/28 07:53
 ************************************************************************/

#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main() {
    pid_t id = fork();
    if (id == 0) {
        printf("i am child process\n");
        sleep(5);
        return 1;
    }
    int status;
    pid_t res = waitpid(-1, &status, 0); 
    if (res > 0) printf("child process exit code:%d\n", WEXITSTATUS(status));
    return 0;
}

